package cn.hhchat.kit.reflecttion;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created this one by HMH on 2017/5/22.
 */
public class ClassUtil {

    static private Logger logger = LoggerFactory.getLogger(ClassUtil.class);

    public static ClassLoader getClassLoader() {
        return Thread.currentThread().getContextClassLoader();
    }

    public static Class<?> loadClass(String className, boolean isInitialized) {
        Class<?> cls;
        try {
            cls = Class.forName(className, isInitialized, getClassLoader());
        } catch (ClassNotFoundException e) {
            logger.error("类加载失败");
            throw new RuntimeException("类加载失败\n",e);
        }
        return cls;
    }
}
